home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUT16.ZIP / TUT16.TXT < prev    next >
Text File  |  1994-09-23  |  9KB  |  199 lines

  1.                    ╒═══════════════════════════════╕
  2.                    │         W E L C O M E         │
  3.                    │  To the VGA Trainer Program   │ │
  4.                    │              By               │ │
  5.                    │      DENTHOR of ASPHYXIA      │ │ │
  6.                    ╘═══════════════════════════════╛ │ │
  7.                      ────────────────────────────────┘ │
  8.                        ────────────────────────────────┘
  9.  
  10.                            --==[ PART 16 ]==--
  11.  
  12.  
  13.  
  14. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. ■ Introduction
  16.  
  17. Hi there. This trainer is on the scaling of an arbitrary sized bitmap to
  18. screen in two dimensions. The sample program seems to work quite quickly,
  19. and the code is document. The scaling procedure is however totally in
  20. assembler ... hopefully this won't cause to many problems.
  21.  
  22. EzE has released a trainer! It is on the speeding up of 3D for normal 3D
  23. and for virtual worlds. Check it out, it is quite good (even though I get
  24. a bit of ribbing in his quote ;-)) It will be in PCGPE ][, to be released
  25. shortly.
  26.  
  27. I have set up a mailserver (that doesn't seem to work all the time, but
  28. the ones that miss I post manually). It works like this :
  29.  
  30. Send mail to denthor@beastie.cs.und.ac.za with the subject line :
  31. request-list ... it will automatically mail you back with a list of
  32. subject lines with which you can grab certain files. You will then mail me
  33. with the subject line of a specific file and it will send you a uuencoded
  34. version of that file automatically. Cool, huh?
  35.  
  36. Remember, no more mail to smith9@batis.bis.und.ac.za, send it all to
  37. denthor@beastie.cs.und.ac.za ! Thanks.
  38.  
  39.  
  40. If you would like to contact me, or the team, there are many ways you
  41. can do it : 1) Write a message to Grant Smith/Denthor/Asphyxia in private mail
  42.                   on the ASPHYXIA BBS.
  43.             2) Write to :  Grant Smith
  44.                            P.O.Box 270 Kloof
  45.                            3640
  46.                            Natal
  47.                            South Africa
  48.             3) Call me (Grant Smith) at (031) 73 2129 (leave a message if you
  49.                   call during varsity). Call +27-31-73-2129 if you call
  50.                   from outside South Africa. (It's YOUR phone bill ;-))
  51.             4) Write to denthor@beastie.cs.und.ac.za in E-Mail.
  52.             5) Write to asphyxia@beastie.cs.und.ac.za to get to all of
  53.                us at once.
  54.  
  55. NB : If you are a representative of a company or BBS, and want ASPHYXIA
  56.        to do you a demo, leave mail to me; we can discuss it.
  57. NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling
  58.         quite lonely and want to meet/help out/exchange code with other demo
  59.         groups. What do you have to lose? Leave a message here and we can work
  60.         out how to transfer it. We really want to hear from you!
  61.  
  62.  
  63.  
  64. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  65. ■  What is scaling?
  66.  
  67. I think that most of you know this one already, but here goes. Let us say
  68. you have a picture (10x10 pixels) and you want to draw it to a different
  69. size (say 5x7 pixel), the process of altering the picture to fit into the
  70. new size is called scaling. Scaling only works on rectangular areas.
  71.  
  72. With scaling to can easily strech and shrink your bitmaps.
  73.  
  74.  
  75. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  76. ■  Okay, so how do we code it?
  77.  
  78. Right. The way I am going to do scaling is as follows :
  79.  
  80. For the horizontal area, I am going to calculate a certain step value. I
  81. will then trace along the bitmap, adding this step to my position, and
  82. placing the nearest pixel on to the screen. Let me explain this simpler ...
  83.  
  84. Let us say I have a 10 pixel wide bitmap. I want to squish it into 5 pixels.
  85. Along the bitmap, I would draw every second pixel to screen. In ascii :
  86.  
  87.   1234567890   13579
  88.   +--------+   +---+
  89.   |        |   |   |
  90.   | bitmap |   |   |dest
  91.   |        |   |   |
  92.   +--------+   +---+
  93.  
  94. As you can see, by stepping through every second pixel, I have shrunk the
  95. bitmap to a width of 5 pixels.
  96.  
  97. The equation is as follows :
  98.  
  99.             step = origionalwidth / wantedwidth;
  100.  
  101. Let us say we have a 100 pixel wide bitmap, which we want to get to 20 pixels.
  102.  
  103.             step = 100 / 20
  104.             step = 5
  105.  
  106. If we draw every fifth pixel from the origional bitmap, we have scaled it down
  107. correctly! This also works for all values, if step is of type real.
  108.  
  109. We also find the step for the height in the same way.
  110.  
  111. Our horizontal loop is as follows :
  112.  
  113.        For loop1:=1 to wantedwidth do BEGIN
  114.          putpixel (loop1,height,bitmap[round (curpos)],vga);
  115.          curpos:=curpos+xstep;
  116.        END;
  117.  
  118. And the vertical loop is much the same. Easy huh? So east in fact, I wrote the
  119. procedure in pure assembler for you ;-) ... don't worry, it's commented.
  120.  
  121. In the sample program, instead of using reals I have used fixed point math.
  122. Refer to tut 14 if you have any hassles with fixed point, it is fairly
  123. straightforward.
  124.  
  125. I also use psuedo 3-d perspective transforms to get the positions smooth...
  126. after Tut8, this should be a breeze.
  127.  
  128. There are no new commands in the assembler for you, so you should get by with
  129. what you learned in tut7/8 ... whew! A lot of back referencing there ;) We
  130. really are building on our knowledge :)
  131.  
  132.  
  133. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  134. ■  In closing
  135.  
  136. Well, that is about it. As you can see the concept is easy, and in fact
  137. fairly obvious, but that didn't stop me from having to sit down with a
  138. pencil and a piece of paper a few months ago and puzzle it out ;-)
  139.  
  140. I have a lot of work ahead of me for a while, so this may be the last
  141. trainer for a few months ... unless I can find some free time available.
  142. So please be patient!
  143.  
  144.  
  145.        [ "Sir! My computer has just gone haywire!"
  146.          "What?" shouts the CO. "That is a multimilliondollar machine!
  147.            find out what's wrong! This is a critical time lieutenant!"
  148.          "Yes sir"
  149.          The young lieutenant furiously types away at the keyboard, but
  150.            the machine totally ignores her.
  151.          "What is going on, soldier?"
  152.          "I don't know sir! It is just doing totally arbitrary things
  153.            after it's assigned tasks are completed. In the computer world
  154.            this is known as Denthorisms."
  155.          The computer starts to make random beeps, and prints out a payroll
  156.            program.
  157.          "Get it working NOW soldier"
  158.          The lieutenant ignores him, and contines typing. She gets partial
  159.            control of the system, she can run programs, but the computer is
  160.            continually running arb tasks in the background. One of the
  161.            techhies who have gathered behing her suddenly cries "Hey! It's
  162.            accessing the missile codes! It wants to launch them!"
  163.          The typing gathers speed, but to no avail. Another techhie says
  164.            "I could disconnect the computer from the link, but that would take
  165.            hours! And this thing will have the codes in under five minutes
  166.            at the speed it's going!"
  167.          A smile forms on the lieutanants face, and she leans back in her chair.
  168.          "What the hell are you doing?" yells the CO. "Why have you stopped?"
  169.          Again ignoring him, the lieutenant instead turns to the techhie. "Go
  170.            disconnect the machine, I know how to get you the time you need."
  171.          "How on earth will you do that? The machines going at top speed!"
  172.          She smiles again, leans forward, types in three letters and hits the
  173.            carriage return. The computer grinds to a halt.
  174.          The smile breaks into a grin. "Maybe it _does_ have it's uses after
  175.            all."
  176.                                                                         ]
  177.                                                          - Grant Smith
  178.                                                              15:30
  179.                                                                23-9-94
  180.  
  181. Byeeeee.....
  182.  
  183. The following are official ASPHYXIA distribution sites :
  184.  
  185. ╔══════════════════════════╦════════════════╦═════╗
  186. ║BBS Name                  ║Telephone No.   ║Open ║
  187. ╠══════════════════════════╬════════════════╬═════╣
  188. ║ASPHYXIA BBS #1           ║+27-31-765-5312 ║ALL  ║
  189. ║ASPHYXIA BBS #2           ║+27-31-765-6293 ║ALL  ║
  190. ║C-Spam BBS                ║410-531-5886    ║ALL  ║
  191. ║POP!                      ║+27-12-661-1257 ║ALL  ║
  192. ║Soul Asylum               ║+358-0-5055041  ║ALL  ║
  193. ║Wasted Image              ║407-838-4525    ║ALL  ║
  194. ║Reckless Life             ║351-01-716 67 58║ALL  ║
  195. ╚══════════════════════════╩════════════════╩═════╝
  196.  
  197. Leave me mail if you want to become an official Asphyxia BBS
  198. distribution site.
  199.